import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:smart_devices/ui/max_line_wrap.dart';
import 'package:smart_devices/ui/my_custom_paint_line.dart';
import 'package:smart_devices/utils/colors.dart';
import 'package:smart_devices/utils/styles.dart';
import 'package:smart_devices/utils/tools.dart';

import 'picture_logic.dart';

class DevicePictureView extends GetView<DevicePictureLogic> {
  const DevicePictureView({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        leading: IconButton(
            icon: const Icon(
              Icons.arrow_back_ios,
              color: Colors.white,
              size: 15,
            ),
            onPressed: Get.back),
        automaticallyImplyLeading: false,
        backgroundColor:
            ColorsUtils.parseColorFromHexString(ColorsUtils.color0052),
        title: Text(
          '设备图片',
          style: StylesUtils.customTextStyle(
              fontSize: 18, fontWeight: FontWeight.w700),
        ),
        centerTitle: true,
      ),
      body: SingleChildScrollView(
        child: Column(
          children: [
            Container(
              margin: const EdgeInsets.only(top: 10),
              color: Colors.white,
              child: ListBody(
                children: [
                  SizedBox(
                    height: 40,
                    child: CustomPaint(
                        painter: MyCustomPaintLine(),
                        child: Container(
                          margin: const EdgeInsets.only(left: 30),
                          alignment: Alignment.centerLeft,
                          child: Text(
                            '设备图片',
                            style: StylesUtils.customTextStyle(
                                color: ColorsUtils.color6666),
                          ),
                        )),
                  ),
                  Container(
                    padding: const EdgeInsets.all(10),
                    alignment: Alignment.centerLeft,
                    child: MaxLineWrap(
                        spacing: 10,
                        runSpacing: 10,
                        itemAlignment: MaxLineWrapAlignment.start,
                        children: controller.imgs
                            .map((String url) =>
                                ToolsUtils.urlImg(url, width: 50, height: 50))
                            .toList()),
                  ),
                ],
              ),
            ),
          ],
        ),
      ),
    );
  }
}
